package deng.qiya.everplay;

import java.io.File;
import java.util.List;
import java.util.concurrent.ExecutionException;

import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageSwitcher;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {

	
	private Context context = null;
	private PlayResourcesConfigure resCfg;
	private File path;
	
	public ImageAdapter(Context context, PlayResourcesConfigure resCfg, File everPlayPath){
		this.context = context;
		this.resCfg = resCfg;
		this.path = everPlayPath;
	}
	
	@Override
	public int getCount() {
		return resCfg.getList().size();
	}

	@Override
	public Object getItem(int position) {
		return resCfg.getList().get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
	/**
		ImageView imageView = null;
		if(convertView == null){
			imageView = new ImageView(context);
			imageView.setLayoutParams(new GridView.LayoutParams(85,85));
			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
			imageView.setPadding(8, 8, 8, 8);
		}
		else{
			imageView = (ImageView)convertView;
		}
		imageView.setImageResource(mThumbIds[position]);
		return imageView;
	**/
		Log.d("lichen ImageView", "Get ImageView now");
		ImageView imageView = null;
		if (convertView != null) {
			imageView = (ImageView)convertView;
		} else {
			imageView = new ImageView(context);
		}
		Log.d("ImageAdapter.class", Constant.RESOURCE_PATH + resCfg.getList().get(position));
		//asyncloadImage(Constant.RESOURCE_PATH + resCfg.getList().get(position).getName(),imageView);
		
		return imageView;
	}

	
//	public void asyncloadImage(String path,ImageSwitcher imageSwitcher) {
//		DownloadService dwnService = new DownloadService();
//		AsyncImageTask task = new AsyncImageTask(dwnService,imageSwitcher);
//		task.execute(path);
//	}



}
